import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import VueRouter from 'vue-router'

import config from '../static/config.js'
import {setCookie, getCookie, delCookie}  from './utils/cookies.js';
import store from './store/index.js'
import routers from './router/index.js'
import App from './App.vue'


// const originalPush = VueRouter.prototype.push
// VueRouter.prototype.push = function push(location) {
// return originalPush.call(this, location).catch(err => err)
// }

Vue.use(ElementUI)

// import Api from './api/index.js';
// Vue.prototype.$api = Api;
const publicPath = 'static/'



import axios from 'axios';
Vue.prototype.$axios = axios;
// Vue.property.setCookie = setCookie ;
// Vue.property.getCookie = getCookie ;
// Vue.property.delCookie = delCookie ;
Vue.prototype.winHeight =window.innerHeight;

  // <p id="api">http://3.kaikaiomg.applinzi.com/interface/api.php</p> 
	 //    <p id="upload">http://3.kaikaiomg.applinzi.com/interface/upload.php</p> 

// var apipath  = document.getElementById("api").innerText
// var uploadpath  = document.getElementById("upload").innerText

// var apipath  ='http://3.kaikaiomg.applinzi.com/interface/api.php';
// var uploadpath  ='http://117.184.168.30:28500/upload';
// var qadb  ='http://117.184.168.30:28500';

// http://218.78.61.116:6021
// Vue.prototype.urlpath =url.innerText;
// console.log(apipath);
// Vue.prototype.urlpath= urlpath;
// Vue.prototype.urlpath= 'test/api/';
//Vue.prototype.kkapipath= '/kkapi';
// Vue.prototype.kkapipath= apipath;
// Vue.prototype.kkuploadpath= uploadpath;
// Vue.prototype.qadb= qadb;
//  http://3.kaikaiomg.applinzi.com/uni_app_download.php
//Vue.prototype.username= "none";





Vue.prototype.gotonginx = function() {
	this.activeName = "-1";
	this.$router.push('/menu')
	clearInterval(this.setTime)
};




console.log("当前地址:",window.location.href)
if( window.location.href.indexOf("localhost") > 0 ){//window.location.href.substr(7,9)=='127.0.0.1' ||
	console.log("是本地运行",);
	 Vue.prototype.kkapipath= '/kkapi';
	 Vue.prototype.kkuploadpath= '/kkupload';
	 Vue.prototype.lpcallfunction= '/lpcallfunction';
	 Vue.prototype.qadb= '/qadb';
	 // Vue.prototype.qadb2= '/qadb2';
}
if( window.location.href.indexOf("192.168.1") > 0 ){
	console.log("是服务器运行",);
	
	 Vue.prototype.qadb='http://192.168.1.99:5002';
	 Vue.prototype.lpcallfunction='http://192.168.1.99:5002/callfunction';
	 Vue.prototype.kkuploadpath= 'http://192.168.1.99:5002/upload';
	 
}
Vue.prototype.choice_web= "web";
if( window.location.href.indexOf("model") > 0 ){
	console.log("模型界面",);
	Vue.prototype.choice_web= "model";
}


Vue.prototype.worker_list=[
	{
		value: '朱秀鹏',
		label: '朱秀鹏'
	},
	
	{
		value: '游雄凯',
		label: '游雄凯'
	},
	{
		value: '胡睦',
		label: '胡睦'
	},
	{
		value: '梁智博',
		label: '梁智博'
	},
	{
		value: '蔡华熠',
		label: '蔡华熠'
	},
	{
		value: '孙啟寅',
		label: '孙啟寅'
	},
	{
		value: '宋逸凡',
		label: '宋逸凡'
	},
	{
		value: '孙张诚',
		label: '孙张诚'
	},
	
	{
		value: '安姣姣',
		label: '安姣姣'
	},
	{
		value: '刘禹',
		label: '刘禹'
	},
	{
		value: '毕于淇',
		label: '毕于淇'
	},
	{
		value: '李想',
		label: '李想'
	},
	{
		value: '尹航',
		label: '尹航'
	},
	{
		value: '陈希瑞',
		label: '陈希瑞'
	},
];


let server_list = []		
let sql ="select server from `config_server` where use_flag='yes'  ;"
axios.post(Vue.prototype.qadb, "form=get_data&sql=" + sql)
    .then(response => {
        if (response.status === 200) {
            for (var i = 0; i < response.data.length; i++) {
                let char = {
                    value: response.data[i]['server'],
                    label: response.data[i]['server'],
                };
                server_list.push(char);
            }
        } else {
            console.log(response.data.statusCode);
        }
    })
    .catch(error => {
        console.log(error);
    });

Vue.prototype.server_list = server_list;
axios.post(Vue.prototype.qadb, "form=get_permission&sql=" + sql)
    .then(response => {
        if (response.status === 200) {
           console.log(response.data);
		   
		   for (var i = 0; i < response.data.length; i++) {
			  if(response.data[i]['name'].length>1){
					store.commit('saveAdminInfo', response.data[i])
			
			  }
			  
		   }
		   // this.$forceUpdate();
			console.log('admininfo',store.state.adminInfo);
        } else {
            console.log(response.data.statusCode);
        }
    })
    .catch(error => {
        console.log(error);
    });



const router = new VueRouter({
  //mode: 'history',
  routes: routers
})


new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})

